package two;

import java.util.Scanner;

public class test8594 {
    private static int num = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        char[] array = new char[n];
        for (int i = 0; i < n; i++) {
            array[i] = s.charAt(i);
        }
        Perm(array, 0, n - 1);
        System.out.println(num);
    }

    private static void Perm(char[] array, int k, int m) {
        if (k == m) {
            num++;
            System.out.println(String.valueOf(array));
        } else {
            for (int i = k; i <= m; i++) {
                if (Findsame(array, k, i))
                    continue;
                Swap(i, k, array);
                Perm(array, k + 1, m);
                Swap(i, k, array);
            }
        }
    }

    private static boolean Findsame(char[] array, int k, int i) {
        for (int j = k; j < i; j++) {
            if (array[j] == array[i]) {
                return true;
            }
        }
        return false;
    }

    private static void Swap(int a, int b, char[] array) {
        char temp = array[a];
        array[a] = array[b];
        array[b] = temp;
    }
}
